<?php

namespace App\Http\Controllers\Api\V1;

use App\Jobs\OptimizePodcast;
use App\Jobs\ProcessPodcast;
use App\Jobs\ReleasePodcast;
use App\Models\Notice;
use App\Transformers\NoticeTransformer;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;

class NoticeController extends Controller
{
    public function index(Request $request)
    {
        $perPage = $request->input('per_page',20);
        $order = $request->input('order','desc');
        $startTime = $request->input('start_time','0');
        $endTime = $request->input('end_time',time());
        $res = Notice::whereBetween('created_at', [$startTime, $endTime])->orderBy('id',$order)->paginate($perPage);

        return $this->response->paginator($res, new NoticeTransformer());

    }

    public function store(Request $request)
    {
        $data = $request->all();
        return Notice::create($data);
    }
}
